<template>
  <div class="add">
    <UnLogin v-if="!hasLogin"></UnLogin>
    <AddForm v-else @success="handleSuccess"></AddForm>
  </div>
</template>
<script>
import { isLogin } from "@/utils";
import UnLogin from "@/components/unlogin";
import AddForm from "@/components/add-form";

export default {
  name: "Add",
  components: { UnLogin, AddForm },
  data() {
    return {
      hasLogin: false,
    };
  },
  created() {
    this.hasLogin = isLogin();
  },
  methods: {
    handleSuccess() {
      this.$toast({
        message: "Success!",
        duration: 1000,
        onClose: () => {
          this.$router.push("/send");
        },
      });
    },
  },
};
</script>
